<?php  
class clsHome
{		 
	var $lng 		= 'vn' ;
	var $tw 		= 'All' ;
	var $pg 		= 1 ;
	var $city_id 	= 0 ;
	var $lm  		= '' ;
	var $start 		= 1 ;
	var $display 	= 10 ;
	var $paging 	= '' ;
	var $totalrow 	= 1000 ;
	var $on 		= "0"  ;
	var $in 		= "0"  ;
	var $sqlCount 	= ""  ;
	var $SEO ;
	var $sql ;  
	
	var $main_url 	= "http://www.giaodichmuaban.net";
	var $lower 		= 'a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|đ|é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|í|ì|ỉ|ĩ|ị|ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|ý|ỳ|ỷ|ỹ|ỵ';
	var $upper 		= 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Đ|É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Í|Ì|Ỉ|Ĩ|Ị|Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Ý|Ỳ|Ỷ|Ỹ|Ỵ';
	var $arrayUpper;
	var $arrayLower;
	
	function __construct (  $tw = 'All' )
	{
		$this->arrayUpper 	= 	explode('|',preg_replace("/\n|\t|\r/","",$this->upper));
		$this->arrayLower 	=	explode('|',preg_replace("/\n|\t|\r/","",$this->lower));
		$this->tw 			=  	$tw ;
		$this->mkSQL() ;
	}
	
	private function mkSQL()
	{
		if($this->tw != 'All')
		{
			$this->sql = "
				SELECT *
				FROM _sanpham_cat_record 
				WHERE id_tinh = ".$this->tw."
				ORDER BY id DESC";
		}else{
			$this->sql = "
				SELECT *
				FROM _sanpham_cat_record  
				ORDER BY id DESC";
		}
		//$this->start 	= ($this->pg - $this->start) * $this->display ;
		//$this->lm 		= " LIMIT ".$this->start.", ".$this->display ;
		//$this->sql 		.= $this->lm ; 
	} 
	
	function san_pham_hot() 
	{
		$sql	=	"select * from _sanpham_cat_record  where published=1 and hot = 1 and id not in (".$this->on.")";
		if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
		$sql	.=	" order by id DESC limit 20 ";
		$result = mysql_query(	$sql	);  
		$return = '';
		$total = @mysql_num_rows($result) ; 
		if( $total > 0 )
		{
			$i=1; 
			while($row = mysql_fetch_array($result))
			{
				$this->on	.=	", ".$row['id'];
				$muaban 	 =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
				$return 	.= '<li>
									<a href="'.$muaban.'-'.$row['seo'].'.html">
									<img src="img/'.$row['image'].'" alt="'.$row['title'].'" /></a>	
									<h5><a href="'.$muaban.'-'.$row['seo'].'.html" >'.$row['title'].'</a></h5>
									<span class="price">'.number_format($row['price'],0,'.','.').'VNĐ</span>							
								</li>';
				$i++;
			} 
			return '<div id="featured-products_block_center">
						<div class="Title"><a href="#">Mua nhiều nhất</a></div>
						<ul id="mycarouse">
							'.$return.'
						</ul>
					</div>';
		}
		return '';
	}
	
	function get_backlink()
	{
		$sql	=	"select * from _backlink  where published=1 ";
		$result = mysql_query(	$sql	);  
		$total = @mysql_num_rows($result) ; 
		$sub	=	"";
		if( $total > 0 )
		 {
			while($item = mysql_fetch_array($result))
			{
				$sub .= '<div class="Cpany"><a class="NameCTY link" href="'.$item['link'].'">'.$item['name'].':</a> '.$item['sub'].'</div>';
			}			  
			return $sub;
		 }
	}
	
	function san_pham_dang_hot() 
	{
		$sql	=	"select * from _sanpham_cat_record where published=1 and buymuch=1 and id not in (".$this->on.") and image<>'' "; //
		if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
		$sql	.=	" order by id DESC limit 4 ";
		$result = mysql_query(	$sql	);  
		$return = '';
		$total = @mysql_num_rows($result) ; 
		if( $total > 0 )
		{
			$return .= '<div class="Title"><a href="#">Sản phẩm đang HOT</a></div>
						<div class="ProductsStyle01">
							<ul>';
			$ssl	=	mysql_query("select * from _banner where published=1 order by ordering DESC limit 1 ");
			$banner	= 	mysql_fetch_array($ssl);
			$return .= '<a class="advLeft" href="'.$banner['link'].'"><img src="img/'.$banner['images'].'"></a> '; 
			$i		=	1; 
			$style	=	' class="line-r" ';
			while($row = mysql_fetch_array($result))
			{
				$this->on	.=	", ".$row['id'];
				$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
				$return .= '<li'.$style.'>
								<a href="'.$muaban.'-'.$row['seo'].'.html">
								<img src="img/'.$row['image'].'" alt="'.$row['title'].'" /></a>	
								<h5><a href="'.$muaban.'-'.$row['seo'].'.html" >'.$row['title'].'</a></h5>
								<p>'.number_format($row['price'],0,'.','.').' VNĐ</p>							
							</li>';
			}
			$return .= '</ul>
					</div>';
			$sql	=	"select * from _sanpham_cat_record where published=1 and buymuch=2 and id not in (".$this->on.") and image<>'' "; //
			if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
			$sql	.=	" order by id DESC limit 5 ";
			$result = mysql_query(	$sql	); 
			$total = @mysql_num_rows($result) ; 
			if( $total > 0 )
			{
				$return .='<div class="clear"></div>
							<div class="ProductsStyle02">
							<ul>';
				while($row = mysql_fetch_array($result))
				{
					$this->on	.=	", ".$row['id'];
					$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
					$return .= '<li'.$style.'>
									<a href="'.$muaban.'-'.$row['seo'].'.html">
									<img src="img/'.$row['image'].'" alt="'.$row['title'].'" /></a>	
									<h5><a href="'.$muaban.'-'.$row['seo'].'.html" >'.$row['title'].'</a></h5>
									<p>'.number_format($row['price'],0,'.','.').' VNĐ</p>							
								</li>';  
				}		
				$return .='</ul>';
			}
			
			$return .='</ul>
							</div>
							<div class="clear"></div>
							';
			return $return;
		}
	}
	
	function load_tabs($town='') 
	{
		$sql	=	"select * from _sanpham_cat_record where published=1 and id not in (".$this->on.") and image<>'' ";
		if($town!='' & $town!='All' ){$sql	.=	" and id_tinh=".$town;}
		$sql	.=	" order by id DESC limit 5";  
		$result = mysql_query(	$sql	);  
		$return = '';
		$total = @mysql_num_rows($result) ; 
		if( $total > 0 )
		{
			while($row = mysql_fetch_array($result))
			{
				$this->on	.=	", ".$row['id'];
				$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
				$return .= '<li class="line-r">
								<a href="'.$muaban.'-'.$row['seo'].'.html"><img alt="'.$row['title'].'" src="img/'.$row['image'].'"></a>
								<ahref="'.$muaban.'-'.$row['seo'].'.html">'.$row['title'].'</a>
								<p>'.number_format($row['price'],0,'.','.').'VNĐ</p>
							</li>'; 
				$i++;
			}
			return '<div class="ProductsStyle01">
                		<ul>'.$return.'</ul>
						<div style=" clear:both"></div>
					</div>';
		}
	}
	
	function san_pham_topcat() 
	{
		$sql	=	"select * from _sanpham_cat order by total DESC limit 3 ";
		$result = mysql_query(	$sql	);  
		$return = '';
		$total = @mysql_num_rows($result) ; 
		if( $total > 0 )
		{
			
			$i		=	1;
			$left 	=	" right";
			$sub	=	"";
			while($row = mysql_fetch_array($result))
			{ 
				$this->on	.=	", ".$row['id'];
				if($left 	==	" left"){	$left 	=	" right";	}
				else{	$left 	=	" left";	}
				$sql	=	"select * from _sanpham_cat_record  where published=1 and  parent=".$row['id']."   ";
				if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
				$sql	.=	" limit 5";
				$data = mysql_query(	$sql	);  
				$total = @mysql_num_rows($data) ; 
				if( $total > 0 )
				{
					$item = mysql_fetch_array($data, MYSQL_ASSOC);
					$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
					$sub .= '<div class="TableProducts'.$left.'">
									<div class="TackNameProducts"><a href="'.$muaban.'-'.$item['seo'].'.html">'.$item['title'].'</a></div>
									<div class="NameProducts">
										<a href="'.$muaban.'-'.$item['seo'].'.html"><img src="img/'.$item['image'].'"></a>
										<a class="Nameitem" href="'.$muaban.'-'.$item['seo'].'.html">'.$item['alias'].'</a>
										<p><span>'.number_format($item['price'],0,'.','.').'VNĐ</span>'.$item['add_date'].'</p>
									</div>
									<div class="clear"></div>
									<ul>';
					$j		=	1; 
					while($item = mysql_fetch_array($data, MYSQL_ASSOC))
					{
						$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
						$tinh = mysql_fetch_array(mysql_query("select * from _town_search where town_id=".$item['id_tinh']));
						$sub .= '<li class="BorderPane">
										<a href="'.$muaban.'-'.$item['seo'].'.html"><img border="0" src="img/'.$item['image'].'"></a>
										<a class="LinkTitle" href="'.$muaban.'-'.$item['seo'].'.html">
										<span class="addTT">'.$tinh['name'].' </span> - '.$item['title'].'</a>
										<a class="dateTT">'.$item['add_date'].'</a>
										<span class="PrizeProDucts">'.number_format($item['price'],0,'.','.').'VNĐ</span>
									</li>';
						$j++;
					}
					$sub .= 		'</ul>
								</div>';
				}
			}
			return  ' <div class="ROOL01">'.$sub.'</div>';
		}
	}
	
	function san_pham_ban_chay() 
	{
		$sql	=	"select * from _sanpham_cat order by total DESC limit 3 ";
		$result = mysql_query(	$sql	);  
		$return = '';
		$total = @mysql_num_rows($result) ; 
		if( $total > 0 )
		{
			
			$i		=	1;
			$left 	=	" right";
			$sub	=	"";
			while($row = mysql_fetch_array($result))
			{ 
				$this->on	.=	", ".$row['id']; 
				$sql	=	"select * from _sanpham_cat_record  where published=1 and  parent=".$row['id']."   ";
				// echo $sql."<br />"; 
				if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
				$sql	.=	" limit 5";
				$data = mysql_query(	$sql	);  
				$totals = @mysql_num_rows($data) ; 
				if( $totals > 0 )
				{
					if($left 	==	" left"){	$left 	=	" right";	}
					else{	$left 	=	" left";	}
					$item = mysql_fetch_array($data, MYSQL_ASSOC);
					$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
					$sub .= '<div class="TableProducts'.$left.'">
									<div class="TackNameProducts"><a href="'.$muaban.'-'.$item['seo'].'.html">'.$item['title'].'</a></div>
									<div class="NameProducts">
										<a href="'.$muaban.'-'.$item['seo'].'.html"><img src="img/'.$item['image'].'"></a>
										<a class="Nameitem" href="'.$muaban.'-'.$item['seo'].'.html">'.$item['alias'].'</a>
										<p><span>'.number_format($item['price'],0,'.','.').'VNĐ</span>'.$item['add_date'].'</p>
									</div>
									<div class="clear"></div>
									<ul>';
					$j		=	1; 
					while($item = mysql_fetch_array($data, MYSQL_ASSOC))
					{
						$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
						$tinh = mysql_fetch_array(mysql_query("select * from _town_search where town_id=".$item['id_tinh']));
						$sub .= '<li class="BorderPane">
										<a href="'.$muaban.'-'.$item['seo'].'.html"><img border="0" src="img/'.$item['image'].'"></a>
										<a class="LinkTitle" href="'.$muaban.'-'.$item['seo'].'.html">
										<span class="addTT">'.$tinh['name'].' </span> - '.$item['title'].'</a>
										<a class="dateTT">'.$item['add_date'].'</a>
										<span class="PrizeProDucts">'.number_format($item['price'],0,'.','.').'VNĐ</span>
									</li>';
						$j++;
					}
					$sub .= 		'</ul>
								</div>';
				}
			}
			return  ' <div class="ROOL01">'.$sub.'</div>';
		}
	}
	
	function home_top_info() 
	{
		$sql	=	"select * from _sanpham_cat_record where published=1 and id not in (".$this->on.")";
		if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
		$sql	.=	" order by id DESC limit 12 ";
		$result = mysql_query(	$sql	);  
		$total = @mysql_num_rows($result) ; 
		$sub	=	"";
		if( $total > 0 )
		{
			while($item = mysql_fetch_array($result))
			{
				$this->on	.=	", ".$item['id']; 
				$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
				$sub .= '<li><a href="'.$muaban.'-'.$item['seo'].'.html">'.$item['title'].'</a></li>'; 
			}			  
			return '<div class="BNcenter">
						<ul>'.$sub.'</ul>
					</div>';
		  }	  
	}
	
	function load_footer()
	{		 
		  $sql	=	"select * from _footer where published= 1 limit 1 ";
		  $result = mysql_query(	$sql	);  
		  $total = @mysql_num_rows($result) ; 
		  $sub	=	"";
		  if( $total > 0 )
		  {
			  	$item = mysql_fetch_array($result);	
				return str_replace('\\','',$item['details']);
		  }	  
	}

	function quangcao() 
	{		 
		  $sql	=	"select * from _quangcao where published= 1 limit 1 ";
		  $result = mysql_query(	$sql	);  
		  $total = @mysql_num_rows($result) ; 
		  $sub	=	"";
		  if( $total > 0 )
		  {
			  	$item = mysql_fetch_array($result);	
				return '<div id="newsAD" class="newsAD"> 
							<div class="left">'.$item['name'].'.<a href="'.$item['link'].'" target="_blank">Xem chi tiết</a></div> 
							<a class="right" href="javascript:void(0);"><img width="14" height="14" border="0" onclick="javascript:document.getElementById(\'newsAD\').style.display=\'none\';" src="images/close.jpg"></a>
						</div>';
		  }	  
	}
	
	function load_slider()
	{
		$sql	=	"select * from _slider where published=1 limit 3 ";  
		  
		$data = mysql_query(	$sql	);  
		$count = @mysql_num_rows($data) ; 
		if( $count > 0 )
		{ 
			$i=1;
			$top		=	"";
			$sub		=	"";
			$selected	=	"selected";
			while($row = mysql_fetch_array($data))
			{
				$top.='<div id="tcontent'.$i.'" class="tabcontent">
					  <a href="'.$row['links'].'"><img src="img/'.$row['image'].'"/></a>
				  </div>';
				$sub.='<li><a href="'.$row['links'].'" rel="tcontent'.$i.'" class="'.$selected.'">'.$row['title'].'</a></li>';
				$selected	=	"";
				$i++;
			}
		}
		return '<div class="Intro">
				  '.$top.'
				  <div id="pettabs" class="modernbricksmenu2">
					  <ul>'.$sub.'</ul>
				  </div>
			  </div>';	
	}

	function home_top_category() 
	{		 
		  $sql	=	"select * from _sanpham_cat ";
		  $result = mysql_query(	$sql	);  
		  $total = @mysql_num_rows($result) ; 
		  $sub	=	"";
		  if( $total > 0 )
		  {
			  while($item = mysql_fetch_array($result))
			  {
				  $sub .= '<option value="'.$item['id'].'">'.$item['title'].'</option>';
			  }
						  
			return $sub;
		  }	  
	}
	
	function right_top_one($catID='', $name='') // muc hot nhat
	{	
		$sql	=	"select * from _sanpham_cat where published=1 and parent =".$catID." limit 4 "; 
	 
		$data = mysql_query(	$sql	);  
		$count = @mysql_num_rows($data) ; 
		if( $count > 0 )
		{ 
			$i=1;
			$top	=	"";
			$sub	=	"";
			while($row = mysql_fetch_array($data))
			{
				$this->in	.=	", ".$row['id'];				
				if($i==1){
					$sql	=	"select * from _sanpham_cat_record where published=1 and parent=".$row['id'] ; // id not in (".$this->on.") and
					if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
					$sql	.=	" order by id DESC limit 4";
					
					$result = mysql_query(	$sql );
					$total = @mysql_num_rows( $result );
					if( $total > 0 )
					{
						while($item = mysql_fetch_array($result))
						{
							$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
							$sub .= '<li>
										  <a href="'.$muaban.'-'.$item['seo'].'.html"><img border="0" src="img/'.( $item['image']!=''?$item['image']:'no-image.png').'"></a>
										  <a class="Linkpane" href="'.$muaban.'-'.$item['seo'].'.html">'.$item['title'].'</a>
										  <p>'.$item['add_date'].'<span>'.number_format($item['price'],0,'.','.').'VNĐ</span></p>
										  <a class="IpIcon">'.$item['alias'].' </a>
									  </li>';
						}
					}
					$top	.=	'<a class="activeTab"  rel="countrycontainer1" href="load_of_cat.php?id='.$row['id'].'">'.$row['title'].'</a>';
				}else{
					$top	.=	'| <a  rel="countrycontainer1" href="load_of_cat.php?id='.$row['id'].'">'.$row['title'].'</a>'; 
				}
				$i++;
			}	
		}
		return '<div class="PaneBlueLight">
				<div class="PaneTitleBlue"><span>'.$name.'</span></div>
					<div class="PaneBody">
							<div class="NewsIP" id="countrytabs1">'.$top.'</div>
							<ul id="countrydivcontainer1">'.$sub.'</ul>
							<div class="clear"></div>
					  </div>
					</div>';
	}
	
	function right_top_two($catID='', $name='',$tab =2 ) 
	{		
		$sql	=	"select * from _sanpham_cat where published=1 and parent =".$catID." limit 4 ";  
		  
		$data = mysql_query(	$sql	);  
		$count = @mysql_num_rows($data) ; 
		if( $count > 0 )
		{ 
			$i=1;
			$top	=	"";
			$sub	=	"";
			while($row = mysql_fetch_array($data))
			{
				$this->in	.=	", ".$row['id'];				
				if($i==1){
					$sql	=	"select * from _sanpham_cat_record where published=1 and  parent=".$row['id'] ; // id not in (".$this->on.") and
					if($this->tw!='All') { $sql	.=	" and id_tinh =".$this->tw; }
					$sql	.=	" order by id DESC limit 4";					 
					$result = mysql_query(	$sql );
					$total = @mysql_num_rows( $result );
					if( $total > 0 )
					{
						$j=1;
						while($item = mysql_fetch_array($result))
						{
							$muaban =	 $item['canban'] ==1 ? 'can-ban':'can-mua' ;
							if($j==1){
								$sub.='<div class="Tinstyle02">
											<a href="'.$muaban.'-'.$item['seo'].'.html"><img src="img/'.($item['image']!=''?$item['image']:'no-image.png').'"/></a>
											<a href="'.$muaban.'-'.$item['seo'].'.html">'.$item['title'].'</a>
											<p>'.$item['add_date'].'</p>
											<p class="prize">'.number_format($item['price'],0,'.','.').'VNĐ</p>
										</div>
										<div class="clear"></div>';
							}else{
								$tinh = mysql_fetch_array(mysql_query("select * from _town_search where town_id=".$item['id_tinh'])); 
								$sub .= '<div class="listTin"><a href="'.$muaban.'-'.$item['seo'].'.html"><span>'.$tinh['name'].'</span>'.$item['title'].'</a></div>'; 
							}
							$j++;
						}
					}
					$top	.=	'<a class="activeTab" rel="countrycontainer1" href="load_of_cat.php?id='.$row['id'].'">'.$row['title'].'</a>';
				}else{
					$top	.=	'| <a class="activeTab" rel="countrycontainer1" href="load_of_cat.php?id='.$row['id'].'">'.$row['title'].'</a>'; 
				}
				$i++;
			}	
		}
		return '<div class="PaneBlueLight">
				<div class="PaneTitleBlue"><span>'.$name.'</span></div>
					<div class="PaneBody">
							<div class="NewsIP" id="countrytabs'.$tab.'">'.$top.'</div>
							<ul id="countrydivcontainer'.$tab.'">'.$sub.'</ul>
							<div class="clear"></div>
					  </div>
					</div>';
	}
	
	function right_top_three() 
	{		 
		$sql	=	"select * from _partner limit 4 ";
		$result = mysql_query(	$sql	);  
		$total = @mysql_num_rows($result) ; 
		$sub	=	"";
		if( $total > 0 )
		 {
			$item = mysql_fetch_array($result);
			$sub .= '	<div class="NewsIP">
								<a href="#">Nhà mới</a> | <a href="#">Nhà mới</a> | 
								<a href="#" class="activeTab">Nhà mới</a> |<a href="#">Nhà mới</a>
						</div>
						<div class="Tinstyle02">
								<a href="'.$item['link'].'"><img src="img/'.($item['images']!=''?$item['images']:'no-image.png').'"/></a>
								<a href="'.$item['link'].'">'.$item['name'].'</a> 
						</div>
						<div class="clear"></div>';
			  
			while($item = mysql_fetch_array($result))
			{
				$tinh = mysql_fetch_array(mysql_query("select * from _town_search where town_id=".$item['id_tinh']));
				$sub .= '<div class="listTin"><a href="'.$item['link'].'"><span>'.$tinh['name'].'</span>'.$item['title'].'</a></div>';
			}			  
			return '<div class="PaneBlueLight">
					<div class="PaneTitleBlue"><span>Tin mới đăng</span></div>
						<div class="PaneBody">'.$sub .'</div>
					</div>';
		 }
	  
	}
	 
	function right_top_four(){
		return '<div class="PaneBlueLight">
					<div class="PaneTitleBlue"><span>Liên kết khác</span></div>
						<div class="PaneBody">
							<div class="NewsIP" id="countrytabs"> 
								<a class="activeTab" rel="countrycontainer" href="load_of_cat.php?id=24" >sắt mỹ thuật</a> | 
								<a rel="countrycontainer" href="load_of_cat.php?id=22">dien thoai</a> | 
								<a rel="countrycontainer" href="load_of_cat.php?id=44">Nhà mới</a>  
							</div>
							<div class="Tinstyle02" id="countrydivcontainer">
								<a href="http://www.vnzooz.com" target="_blank" ><img src="images/sat-my-thuat-tan-hung.jpg"></a>
								<a href="#">Căn hộ cần bán với giá rẻ bất ngờ..</a>
								<p>2012/12/02</p>
								<p class="prize">45 tỷ</p>
							</div>
							<div class="clear"></div>
							'.$this->get_backlink().'
						  </div>
					</div>';
	}
	 
	function get_right_hot()
	{
		$sql	=	"select * from _sanpham_cat where hotright > 0 order by hotright DESC, ordering DESC limit 4 "; 
		$data 	= 	mysql_query(	$sql	);
		$count 	= 	@mysql_num_rows($data) ;
		$return	=	'';
		if( $count > 0 )
		{
			$row 	= 	mysql_fetch_array($data);
			$return	.=	$this->right_top_one($row['id'],$row['title']); 
			
			$row 	= 	mysql_fetch_array($data);
			$return	.=	$this->right_top_two($row['id'],$row['title'],2);
			
			$row 	= 	mysql_fetch_array($data);
			$return	.=	$this->right_top_two($row['id'],$row['title'],3);
			
			$row 	= 	mysql_fetch_array($data);
			$return	.=	$this->right_top_two($row['id'],$row['title'],4);
			
			//$return	.=	$this->right_top_three();
			
			$return	.=	$this->right_top_four();
			
			
		}
		return $return;
		
	}
	
	function get_day($time) 
	{
		$times 	= time();
		$day 	= 86400; 
		$dates = $times - ($day * $time);
		 return date("Y/m/d", $dates );
	} 
	
	function lower( $str )
	{
		return str_replace($this->arrayUpper,$this->arrayLower,$str);
	}
		
	function upper( $str )
	{

		return str_replace($this->arrayLower,$this->arrayUpper,$str);
	}
	
	function vn_str_filter( $str)
	{  
		$unicode = array(  
			'a'=>'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',  
			'd'=>'đ',  
			'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',  
			'i'=>'í|ì|ỉ|ĩ|ị',  
			'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',  
			'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',  
			'y'=>'ý|ỳ|ỷ|ỹ|ỵ',  
			'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',  
			'D'=>'Đ',  
			'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',  
			'I'=>'Í|Ì|Ỉ|Ĩ|Ị',  
			'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',  
			'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',  
			'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ',  
		);  
		  
	   foreach($unicode as $nonUnicode=>$uni){  
			$str = preg_replace("/($uni)/i", $nonUnicode, $str);  
	   }  
		return $str;  
	} 
	
	
}

?>